package com.nowcoder.utils;

import com.nowcoder.entity.User;
import org.springframework.stereotype.Component;

// 持有用户，代替Session
public class HostHolder {
    static private ThreadLocal<User> threadLocal = new ThreadLocal<>();
    public static void setUser(User user) {
        threadLocal.set(user);
    }
    public static User getUser() {
        return threadLocal.get();
    }
    public static void clear() {
        threadLocal.remove();
    }
}
